package com.huwaiwai.disruptor.demo03;

import com.lmax.disruptor.RingBuffer;
import lombok.AllArgsConstructor;

import java.nio.ByteBuffer;

/**
 * Created by huweiwei on 2017/5/15.
 */
@AllArgsConstructor
public class Demo03Producer {

    private final RingBuffer<PCData> ringBuffer;

    public void push(ByteBuffer bb){
        long sequence = ringBuffer.next();
        try {
            PCData event = ringBuffer.get(sequence);
            event.setValue(bb.getLong(0));
        } finally {
            ringBuffer.publish(sequence);
        }
    }
}
